package com.logic.modular.gameCore.cultivate.prop;

import com.comment.pojo.domain.logic.core.CoreProp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.comment.util.message.ResponseResult;

import java.util.List;
import java.util.stream.Collectors;


/**
 * 道具表(CoreProp)表服务控制层
 *
 * @author cxy
 * @since 2024-08-05 18:15:26
 */
@Api(tags = "道具表(CoreProp)") 
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/coreProp")
public class CorePropController {
    @Resource
    private CorePropServiceImpl corePropService;
    
    @ApiOperation("获取道具表列表")
    @PostMapping("/list")
    public ResponseResult<List<CoreProp>> list() {
        return ResponseResult.success(CorePropServiceImpl.listCache());
    }

    @ApiOperation("获取道具表列表")
    @GetMapping("/listBy")
    public ResponseResult<List<CoreProp>> listBy(
            @RequestParam(value = "startId", required = false) Long startId,
            @RequestParam(value = "endId", required = false) Long endId
    ) {
        return ResponseResult.success(CorePropServiceImpl.listCache().stream().filter(item -> item.getId().compareTo(startId) >= 0 && item.getId().compareTo(endId) <= 0
        ).collect(Collectors.toList()));
    }
}
